Skip to content

Conversation

@AbdelrahmanHafez
Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez commented Nov 30, 2025

@AbdelrahmanHafez AbdelrahmanHafez requested review from Copilot, hasezoey and vkarpov15 and removed request for Copilot and hasezoey November 30, 2025 00:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds TypeScript type definitions for the overwriteImmutable option in bulkWrite operations, addressing issue #15781. The option allows updating fields marked as immutable in the schema during updateOne and updateMany operations within bulkWrite.

Key Changes:

  • Added overwriteImmutable?: boolean type to UpdateOneModel and UpdateManyModel interfaces
  • Added TypeScript type tests to verify the new option types
  • Refactored existing JavaScript test for better structure and clarity
  • Updated tdd npm script with more specific watch patterns

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
types/models.d.ts Added overwriteImmutable option to UpdateOneModel and UpdateManyModel interfaces
test/types/models.test.ts Added type test coverage for overwriteImmutable, resolved import naming conflict with MongoDB driver
test/model.updateOne.test.js Refactored test into nested describe block with better organized test cases using Arrange-Act-Assert pattern
package.json Updated tdd script with quoted glob patterns and added trailing newline

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

package.json Outdated
"setup-test-encryption": "node scripts/setup-encryption-tests.js",
"test-encryption": "mocha --exit ./test/encryption/*.test.js",
"tdd": "mocha ./test/*.test.js --inspect --watch --recursive --watch-files ./**/*.{js,ts}",
"tdd": "npx mocha ./test/*.test.js --inspect --watch --recursive --watch-files 'test/**/*.js' --watch-files 'lib/**/*.js'",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As copilot already pointed out, why is this change necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created the tdd script long time ago, but it's broken now. I'm guessing this is because of a change in the type-testing approach, IIRC we didn't start with tsd as our type testing tool.

Anyway, the new script fixes the errors from the old script. It's not really used as part of any automation so it's safe to change.

@hasezoey hasezoey added the typescript Types or Types-test related issue / Pull Request label Nov 30, 2025
@AbdelrahmanHafez AbdelrahmanHafez changed the title fix(types): add overwriteImmutable types re #15781 fix(model): fix overwriteImmutable not working with timestamps: true, add overwriteImmutable types re #15781 Dec 3, 2025
@AbdelrahmanHafez AbdelrahmanHafez added the confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. label Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. typescript Types or Types-test related issue / Pull Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants